1. Field of the Invention
The present invention relates to an image processing apparatus for compressing image data, to a compression method used in an image processing apparatus, and to a storage medium for storing programs thereof.
2. Description of the Related Art
Demand for high-resolution color images has steadily risen up to now, and digital copiers routinely handle images whose resolution is 1200 dpi or higher. As the resolution of images has risen, there has been a dramatic leap in the number of pixels that have to undergo image processing, and this has sent the processing load even higher. For example, when the resolution doubles from 600 dpi to 1200 dpi, the number of pixels that have to be processed quadruples. This is not limited to digital copiers, and even with digital cameras, facsimile devices, and other such image processing apparatus, the compression of color image data is performed in order to shorten processing time by reducing the memory/hard-disk space or shortening how long it takes to write to these media.
Compression formats that are commonly used for color still pictures include the JPEG format, which makes use of a discrete cosine transform, and a format featuring a wavelet transform. With such coding formats, generally image data is encoded in specific blocks (such as 8×8 pixel or 16×16 pixel units), and discrete cosine transform, quantization, and entropy encoding are performed to achieve a high compression efficiency. Such coding formats are variable length coding formats, so the amount of coding varies for each group of image data to be coded.
After the image data has been compressed by one of the methods discussed above, it is necessary to decode the compressed image data, in order to process the image data using that image data as reference, since no image processing can be performed with the compressed image data the way it is. Therefore, decoding processing is required in pixel units with respect to all pixels of high resolution data, which causes processing time increase.
Also, the compression method can be a known run-length compression method in which pixel data and the run length thereof are stored, or the method discussed in Japanese Patent Laid-Open No. 2008-271046, in which the amount of data is compressed by performing color reduction to two colors or less for each block, and outputting color data for two colors and the layout pattern of those two colors.
With the method in Japanese Patent Laid-Open No. 2008-271046, there are always two or fewer colors in a block, but to further enhance picture quality, the applicant also considers a technique in which, with a 2×2 block, a maximum of four colors is allowed for each block in compression. In the proposal in Japanese Patent Application No. 2009-221444, first the image data is divided into blocks (such as blocks with a size of 2×2 pixels), and the color data for the pixels in the block are compared, so that layout pattern information about the color data included in a block of interest and color data information for the number of colors included in the block of interest are outputted. The outputted color data information is divided into first color data information corresponding to a pixel in a predetermined position of the block (color data information for the upper-left pixel in a block with a size of 2×2 pixels), and other color data information (second to fourth color data information), which are stored in a memory region. Specifically, a technique is proposed in which the layout pattern information obtained for the blocks, the first color data information, and the other color data information are compiled and stored each in different memory regions. Also, with the proposal in Japanese Patent Application No. 2009-221444, in comparing the color data for the blocks, it is possible to compare the difference in color between pixels in the block (pixel value) with a threshold, perform color reduction if the difference is less than this threshold, and thereby increase the compression ratio.
On the other hand, the original image can be reproduced more faithfully when color reduction is performed as little as possible, so although reducing the threshold of color reduction processing does afford better picture quality, it ends up lowering the compression ratio. Also, depending on the system, there may be situations in which there is a limit to the memory size that can be used to store one page of image data, for example. When color reduction is performed according to the proposal in Japanese Patent Application No. 2009-221444, how much the amount of data is reduced according to the threshold of color reduction will vary with the image being processed, and therefore is not known before the color reduction is performed. Thus, to maintain the picture quality as high as possible while keeping the amount of data at or under a target compression ratio for a given set of input image data, recompression has to be repeated while varying the threshold setting until that compression ratio is attained, and as a result, the compression processing takes a long time until the target value is reached.